# $Id: PKGBUILD 66264 2012-02-23 05:38:22Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: William Rea <sillywilly@gmail.com>

pkgname=openthreads
pkgver=2.3.0
pkgrel=2
pkgdesc="A  minimal & complete Object-Oriented thread interface for C++ programmers"
arch=('i686' 'x86_64')
url="http://openthreads.sourceforge.net"
license=("LGPL")
depends=('gcc-libs')
makedepends=('cmake')
source=(http://www.openscenegraph.org/downloads/developer_releases/OpenThreads-$pkgver.zip)
md5sums=('ab4899c9d11e3917bd5f1401d6d0af11')

build() {
  cd "$srcdir/OpenThreads-$pkgver"

  sed -i 's#-lpthreads#-lpthread#' CMakeModules/FindThreads.cmake
  sed -i 's#SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}")#SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")#' src/OpenThreads/pthreads/CMakeLists.txt

  cmake . -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr

  make
}

package() {
  cd "$srcdir/OpenThreads-$pkgver"

  sed -i 's#lib64#lib#' src/OpenThreads/pthreads/cmake_install.cmake
  make DESTDIR="$pkgdir" install

  install -D packaging/pkg_config/openthreads.pc ${pkgdir}/usr/lib/pkgconfig/openthreads.pc
}
